package IC.lir;

import java.util.*;

import IC.lir.Instrunction.Label;
import IC.lir.Instrunction.LabelDecl;

public class Lir 
{
	public LinkedList<LirFunction> Functions = new LinkedList<LirFunction>();
	public HashMap<String, ClassStructure> ClassStructures = new HashMap<String, ClassStructure>();
	public LiteralStack Literals = new LiteralStack();
	public Label ProgramEndLabel = new Label("");
	
	public String toString()
	{
		String ret = Literals.toString() + "\n";
		
		for (Map.Entry<String, ClassStructure> classStruct : ClassStructures.entrySet())
			ret += String.format("_DV_%s: %s\n", classStruct.getKey(), classStruct.getValue().StringDispatchContent());
		ret += "\n";
		
		for (LirFunction func : Functions)
			ret += func.toString() + "\n";
		
		ret += new LabelDecl(ProgramEndLabel).toString();
		
		return ret;
	}
}
